package poli.tidia.mobile;

import poli.tidia.mobile.model.Announcement;
import poli.tidia.mobile.proxy.AnnouncementsProxy;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.widget.LinearLayout;
import android.widget.TextView;

public class AnnouncementDetailsActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
		Bundle b = getIntent().getExtras();
    	if (b != null) {
    		String selectedAnnoucementUrl = b.getString("selectedAnnouncement");

    		AnnouncementsProxy annProxy = new AnnouncementsProxy();
    		Announcement selectedAnnouncement = annProxy.getAnnouncement(selectedAnnoucementUrl);
     
            TextView textView = new TextView(this);
            textView.setText("Assunto: " + selectedAnnouncement.getSubject() + "\n\nAutor: " + selectedAnnouncement.getAuthor() + "\n\nData: " + selectedAnnouncement.getCreated().toLocaleString() + "\n\nMensagem:\n" + selectedAnnouncement.getMessage());

            LinearLayout layout = new LinearLayout(this);
            layout.setBackgroundColor(Color.WHITE);
            layout.addView(textView);
            setContentView(layout);
    	}
	}
}
